<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button onclick="throttleClick()"></button>
  </body>
  <script>
    function myThrottle(fn, delay) {
      let timer;
      return function () {
        let context = this;
        let args = arguments;
        if (!timer) {
          timer = setTimeout(() => {
            fn.apply(context, [...args]);
            timer = null;
          }, delay);
        }
      };
    }

    const throttleClick = myThrottle(() => {
      console.log("click");
    }, 2000);
  </script>
</html>
